var status = 0;
var chosen;
var increase = 0;
var statup = new java.util.ArrayList();

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0 && status == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			cm.sendSimple("#eA or B? You can win prizes#n\r\nWin #r3#k Times to get your price!\r\n#L1##bA#k#l\r\n#L2##bB#k#l");
			chosen = Math.floor(Math.random()*2+1);
		}
		if (status == 1) {
			if (increase == 2) {
				cm.sendOk("You made it! Here, take 75k Exp and Mesos!");
				cm.gainExp(75000);
				cm.gainMeso(75000);
				cm.dispose();
			} else {
				if (selection == chosen) {
					status = -1;
					chosen = Math.floor(Math.random()*2+1);
					increase = (increase + 1);					
					cm.sendNext("Good! Now only #e" + (3 - increase) + "#n times to go!");
				} else {
					var currenthp = cm.getChar().getHp();
					cm.getChar().setHp(currenthp - 100);
					statup.add (new net.sf.odinms.tools.Pair(net.sf.odinms.client.MapleStat.HP, java.lang.Integer.valueOf(cm.getChar().getHp())));
					cm.sendOk("Wrong, you won't get a price now\r\nI also decreased your HP with 100!");
					cm.dispose();
				}
			}
		}
	}
}